package com.example.lirisheng.springbootfinalexperiment.service;

import com.example.lirisheng.springbootfinalexperiment.entity1.PerInfoEntity;
import com.example.lirisheng.springbootfinalexperiment.entity1.ResAuthoritiesEntity;
import com.example.lirisheng.springbootfinalexperiment.entity1.ResidentEntity;
import com.example.lirisheng.springbootfinalexperiment.repositories.AuthoritiesRepository;
import com.example.lirisheng.springbootfinalexperiment.pojo.RegistryEntity;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Commit;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

@SpringBootTest
@Transactional
public class ResidentService {

    @Autowired
    ResService resService;

    @Autowired
    AuthoritiesRepository authoritiesRepository;

//    @Test
//    @Commit
//    public  void  registryResident(){
//        ResidentEntity residentEntity = new ResidentEntity();
//        residentEntity.setUsername("user1");
//        residentEntity.setPassword("password");
//        residentEntity.setOpenId("111");
//        ResAuthoritiesEntity resAuthoritiesEntity=new ResAuthoritiesEntity();
//        resAuthoritiesEntity.setUsername("user1");
//        resAuthoritiesEntity.setAuthority("USER");
////        resAuthoritiesEntity.setResidentEntity(residentEntity);
//        PerInfoEntity perInfoEntity=new PerInfoEntity();
//        perInfoEntity.setIdentity("44028131995");
//        perInfoEntity.setHouse_id(1);
//        perInfoEntity.setName("马云");
////        perInfoEntity.setResidentEntity(residentEntity);
//        perInfoEntity=resService.registryResident(residentEntity,resAuthoritiesEntity,perInfoEntity);
////        System.out.println("resAuthoritiesEntity"+authoritiesRepository.findByUsername("bbb"));
//        System.out.println(perInfoEntity);
//    }
//
//    @Test
//    @Rollback
//    public  void judgeRegistryInfo(){
//        RegistryEntity registryEntity = new RegistryEntity();
//        registryEntity.setUsername("user13");
//        registryEntity.setPassword("1234");
//        registryEntity.setOpen_id("2223");
//        registryEntity.setName("马云");
//        registryEntity.setIdentity("4402813199fdsf5");
//        registryEntity.setHouseId(9);
//        Map<String,Object> map = resService.judgeRegistryInfo(registryEntity);
//        System.out.println(map);
//    }
}
